<meta charset="UTF-8">
	<script type="text/javascript">
	$(function(){
		$('#g_formButton').click(function(){
			//var g_date = $("#g_laydate").val();
			var g_teacher = $("#g_teacher").val();
			var g_classroom = $("#g_classroom").val();
			var g_repairTime = $("#g_repairTime").val();
			var g_sj = $("#g_sj").val();
			if(g_repairTime!=""&&g_sj=="--请选择节次--"){
				bootbox.alert("系统检测到您有换时间申请，请选择节次！");
				return false;
			}else if(g_repairTime==""&&g_sj!="--请选择节次--"){
				bootbox.alert("系统检测到您有换时间申请，请选择日期！");
				return false;
			}else if(g_teacher=="--请选择老师--"&&g_classroom=="--请选择地点--"&&g_repairTime==""){
				bootbox.alert("您没有选择需要调课的内容！");
				return false;
			}
			var serial= $("#g_myForm").serialize();
			$.ajax({
			    type: 'post',
			    url: '../ttb/g_tk_saveTeacherRecord',
			    data: serial,
			    success: function(data) {
			    	bootbox.alert(data.msg);
			    },error:function(data){
			    	bootbox.alert(data.msg);
			    }
			});
			
		});
		$('#g_teacher').selectpicker({	//初始化下拉框
			title:'换老师'
			//width:'fit'
		}); 
		$('#g_classroom').selectpicker({	//初始化下拉框
			title:'换地点'
			//width:'fit'
		}); 
		$('#g_sj').selectpicker({	//初始化下拉框
			title:'换地点'
			//width:'fit'
		}); 
		//获取当前时间
		var date = new Date();   //得到的不是常规格式
		//转为常规格式
		var d = date.toLocaleString();
		//获取当前年
		var year = date.getFullYear();
		//获取当前月
		var month = date.getMonth()+1;
		//获取当前日
		var day = date.getDate();
		//获取当前小时
		var hours = date.getHours();
		//获取当前分钟
		var minutes = date.getMinutes();
		//获取当前秒
		var seconds = date.getSeconds();
		var dat = year+"-"+month+"-"+day;   //当前日期
		var dat1 = year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;   //当前日期时间
		
		//layui日期插件
		laydate.render({
		  	elem: '#g_laydate',
		  	calendar: true,
			min:minDate()
			
		});
		laydate.render({
		  	elem: '#g_repairTime',
		  	calendar: true,
			min:minDate()
		});
	});
	// 设置最小可选的日期
	function minDate(){
	    var now = new Date();
	    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
	 }
	</script>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal"
		aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h3 class="modal-title">调课申请<span style="font-size: 14px;">（如果您只想调老师或地点或时间可选中其中一项进行调课）</span></h3>
</div>

<form id="g_myForm">

<div id="tk_information" >
	<div id="g_header" class="col-md-12" >
	
		<div class="input-group col-md-4"style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon ">时间</span> 
			<input type="text" class="form-control" name="suspendTime" readonly="readonly" data-th-value="${model.time}"/>
		</div>
		<div class="input-group col-md-4"style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon ">年级</span> 
			<input type="text" class="form-control" name="year" readonly="readonly" data-th-value="${model.year}"/>
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">班级</span> 
			<input type="text"class="form-control" name="tbClass" readonly="readonly" data-th-value="${model.classes}" />
		</div>
		<div class="input-group col-md-4"style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon ">课程</span> 
			<input type="text" class="form-control" name="curriculum" readonly="readonly" data-th-value="${model.course}"/>
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">教室</span> 
			<input type="text"class="form-control" name="classroom" readonly="readonly" data-th-value="${model.classRoom}" />
		</div>
		
		
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">星期</span> 
			<input type="text"class="form-control"name="week" readonly="readonly" data-th-value="${model.week}" />
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">节次</span> 
			<input type="text"class="form-control"name="section" readonly="readonly" data-th-value="${model.jc}" />
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">应到人数</span> 
			<input type="text"class="form-control"name="ydrs" readonly="readonly" data-th-value="${model.ydrs}" />
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">调课类型</span> 
			<input type="text"class="form-control" readonly="readonly" data-th-value="其他" />
		</div>
	</div>
</div>
	<div id="g_fou" style="margin-top: 80px;">
		<div id="tk_home" class="col-md-12" style="margin-top: 10px;">
			<div id="g_hls" class="col-md-3">
				<select class="form-control" name="teacher" id="g_teacher"data-live-search="true" >
					<option style="display: none;">--请选择老师--</option>
					<option  th:each="t:${g_list1}" th:value="${t.name}" ><span th:text="${t.name}"></span></option>
				</select>
			</div>
			
			<div id="g_hdd"class="col-md-3" >
				<select class="form-control" name="address"id="g_classroom"data-live-search="true" >
					<option style="display: none;">--请选择地点--</option>
					<option th:each="c:${g_classroom}"  th:text="${c.serialNumber}"><span></span></option>
				</select>
			</div>
			
		<div id="g_hdj"class="col-md-6" >
			<div class="input-group has-feedback col-md-7"style="float: left; ">
				<span class="input-group-addon">上课日期</span> 
				<input type="text" class="form-control"  name="repairTime" placeholder="选择上课日期" id="g_repairTime"  />
				<span class="glyphicon glyphicon-calendar form-control-feedback"></span>
			</div>
			<div class="col-md-5" >
				<select class="form-control" id="g_sj"data-live-search="true" name="jc">
					<option style="display: none;">--请选择节次--</option>
					<option>1-2</option>
					<option>3-4</option>
					<option>5-6</option>
					<option>7-8</option>
					<option>9-10</option>
				</select>
			</div>
		</div>	
	</div>
</div>
</form>
<br><br><br><br><br><br><br><br>
<div class="modal-footer">
	<button type="button" class="btn btn-success" data-dismiss="modal" id="g_formButton">
		<span class="glyphicon glyphicon-ok"></span> 提交申请
	</button>
	<button type="button" class="btn btn-danger" data-dismiss="modal">
		<span class="glyphicon glyphicon-remove"></span> 关闭
	</button>
</div>